﻿//-----------------------------------------------------------------------
// <copyright>
// This file is subject to the terms and conditions of the Microsoft Public License (MS-PL).
// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL for more details.
// </copyright>
//----------------------------------------------------------------------- 
using Fulcrum.ControlGenerator;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Fulcrum.UnitTests.ControlGenerator
{
    [TestClass]
    public class RoutedEventDataContextTests
    {
        public RoutedEventDataContextTests()
        {
            // nothing
        }

        [TestMethod]
        public void TestEventArgsType()
        {
            var config = CreateConfig();

            var routedEvent = new RoutedEventDataContext(config);

            Assert.AreEqual("EventArgs", routedEvent.EventArgsType);
        }

        [TestMethod]
        public void TestHandlerType()
        {
            var config = CreateConfig();

            var routedEvent = new RoutedEventDataContext(config);

            Assert.AreEqual("EventHandler", routedEvent.HandlerType);
        }

        [TestMethod]
        public void TestName()
        {
            var config = CreateConfig();

            var routedEvent = new RoutedEventDataContext(config);

            Assert.AreEqual("BlahBlah", routedEvent.Name);
        }

        [TestMethod]
        public void TestRemarks()
        {
            var config = CreateConfig();

            var routedEvent = new RoutedEventDataContext(config);

            Assert.AreEqual("my remarks", routedEvent.Remarks);
        }

        [TestMethod]
        public void TestRoutedEventName()
        {
            var config = CreateConfig();

            var routedEvent = new RoutedEventDataContext(config);

            Assert.AreEqual("BlahBlahEvent", routedEvent.RoutedEventName);
        }

        [TestMethod]
        public void TestRoutingStrategy()
        {
            var config = CreateConfig();

            var routedEvent = new RoutedEventDataContext(config);

            Assert.AreEqual("Bubble", routedEvent.RoutingStrategy);
        }

        [TestMethod]
        public void TestSummary()
        {
            var config = CreateConfig();

            var routedEvent = new RoutedEventDataContext(config);

            Assert.AreEqual("my summary", routedEvent.Summary);
        }

        private static MockRoutedEventConfiguration CreateConfig()
        {
            var config = new MockRoutedEventConfiguration();

            config.Name = "BlahBlah";
            config.Remarks = "my remarks";
            config.Summary = "my summary";
            config.HandlerType = "EventHandler";
            config.EventArgsType = "EventArgs";
            config.RoutingStrategy = "Bubble";

            return config;
        }
    }
}
